//
//  CollectDetailViewController.m
//  减肥,美容老中医偏方
//
//  Created by appying_wxj on 14/12/4.
//  Copyright (c) 2014年 陈朕. All rights reserved.
//

#import "CollectDetailViewController.h"

@interface CollectDetailViewController ()

@end

@implementation CollectDetailViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        appBean = [AppBean shareInstence];

        // 导航条上面的字体
        UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, boundswidth-120, 44)];
        navLabel.text = appBean.title;
        navLabel.textColor = [UIColor colorWithRed:1 green:0.94 blue:0.82 alpha:1];
        navLabel.font = [UIFont systemFontOfSize:18];
        navLabel.textAlignment = NSTextAlignmentCenter;
        self.navigationItem.titleView = navLabel;

//        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bgIMG"]];
        self.view.backgroundColor = [UIColor whiteColor];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    //导航条左边返回按钮
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CGRectMake(0, 0, 50, 44);
//    backButton.showsTouchWhenHighlighted = YES;// 按钮按下时会发光
    [backButton setBackgroundImage:[UIImage imageNamed:@"image_back"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftItem;

    
    
    appBean = [AppBean shareInstence];
    
    UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, boundswidth, boundsheight)];
    webView.backgroundColor = [UIColor clearColor];
    webView.opaque = NO;
    
    NSURL *url = [NSURL URLWithString:appBean.url];
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
    [self.view addSubview:webView];
}
// 导航条上面的返回按钮
-(void)backButtonClick:(UIButton *)sender{
//    [self.navigationController popToRootViewControllerAnimated:YES];
    [self.navigationController popToViewController:
     
     [self.navigationController.viewControllers objectAtIndex:
      
      ([self.navigationController.viewControllers count] -2)] animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
